#!/bin/bash

# 启动 MQTT 客户端订阅 Vendor1 和 Vendor2 主题
# 用法: bash start_mqtt_vendor2.sh

echo "========== 启动 MQTT 客户端 (Vendor1 + Vendor2) =========="
echo ""
echo "订阅主题: tc/device/out/#, rziot/zftx_w06/#"
echo ""

# 杀死旧的 MQTT 客户端进程
echo "【第一步】停止旧的 MQTT 客户端..."
pkill -f "mqtt:client" || true
sleep 2

# 启动新的 MQTT 客户端
echo "【第二步】启动新的 MQTT 客户端..."
php think mqtt:client &

echo ""
echo "✅ MQTT 客户端已启动"
echo ""
echo "订阅主题:"
echo "  - tc/device/out/#  (Vendor1)"
echo "  - rziot/zftx_w06/# (Vendor2)"
echo ""
echo "QoS: 0"
echo ""
echo "现在可以发送 Vendor1 和 Vendor2 消息了"
echo ""
echo "停止客户端: pkill -f 'mqtt:client'"
echo ""
echo "查看日志: tail -f runtime/log/2025_11_28.log"

